//https://leetcode.cn/problems/teemo-attacking/
class Solution {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int ret = 0;
        int len = timeSeries.length;
        for(int i = 0; i < len - 1; i++) {
            int x = timeSeries[i + 1] - timeSeries[i];
            if(x >= duration) {
                ret += duration;
            }else {
                ret += x;
            }
        }
        ret += duration;
        return ret;
    }
}